<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function getVal(x) {
            var link = 'http://locallhost:8080?id=10&name=zhangsan&class=box';

            var first = link.split('?')[1].split('&');

            first.forEach((item, index) => {
                var pair = item.split('=');
                if (pair[0] == x) {
                    console.log(pair[1]);
                }
            })
        }
        getVal('name')
    </script>
</body>

</html>